var behaviorApi = function (theInterface) {
    var link = '';
    if (location.host.indexOf('t.m.antfre.com') > -1) {
        link = "http://t.behavior.antfre.com" + theInterface;
    }
    else if (location.host.indexOf('m.antfre.com') > -1){
        link = "https://behavior.antfre.com" + theInterface;
    }
    else {
        link = "http://t.behavior.antfre.com" + theInterface;
    }

    return link;
};
(function( $ ){
    window.behavior = {
        url: behaviorApi('/api/behavior/data'),
        track: function (name, attr) {
            $.ajax({
                url: this.url,
                data: {
                    app_key: "antfresh",
                    user: JSON.parse(decodeURIComponent(JSON.parse(window.localStorage.user).redirect)).userId,
                    name: name,
                    attr: attr
                },
                type: 'POST'
            });
        }
    }
})( jQuery );
